//2024-09-24

function main() {
    //原始最小最大值
    const vmin0 = 50;
    const vmax0 = 128;
    //新的最小最大值
    const vmin1 = 0;
    const vmax1 = 255;
    
    let oldDs = pe.Dataset("world", 20000101000000 );
    oldDs = oldDs.extract(0);//提取一个波段做测试
    oldDs = oldDs.toFloat32();
    //equation (pixel-min0)/(max0-min0) * (max1-min1) + min1
    let newDs=oldDs.clone();
    newDs.subConst(vmin0,0);
    newDs.divConst( vmax0-vmin0,0 );
    newDs.mulConst(vmax1-vmin1,0);
    newDs.addConst(vmin1,0);
    
    let maskDs = pe.NewDataset(1,256,256,1,1);// 正掩膜，在ROI内为1，外部为0
    maskDs = maskDs.clip3('henansheng.geojson',0);
    
    let invMaskDs = pe.NewDataset(1,256,256,1,0);// 负掩膜，在ROI内为1，外部为0
    invMaskDs=invMaskDs.clip3('henansheng.geojson',1);
    
    newDs = newDs.mul(maskDs, 0, 10000, 0 ).add( oldDs.mul(invMaskDs,0,10000,0) , 0,10000, 0 ) ;
    return newDs ;
}